package com.example.chamberlainserver.mapper;

import com.example.chamberlainserver.Entry.Department;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 部门Mapper接口
 */
@Mapper
public interface DepartmentMapper {
    /**
     * 获取所有部门
     */
    List<Department> getAllDepartments();
    
    /**
     * 根据ID获取部门
     */
    Department getDepartmentById(@Param("id") Integer id);
    
    /**
     * 根据部门代码获取部门
     */
    Department getDepartmentByCode(@Param("code") String code);
    
    /**
     * 添加部门
     */
    int insertDepartment(Department department);
    
    /**
     * 更新部门
     */
    int updateDepartment(Department department);
    
    /**
     * 删除部门
     */
    int deleteDepartmentById(@Param("id") Integer id);
    
    /**
     * 获取部门下的所有用户
     */
    List<Integer> getUserIdsByDepartmentId(@Param("departmentId") Integer departmentId);
    
    /**
     * 检查部门代码是否唯一
     */
    boolean isDepartmentCodeUnique(@Param("code") String code, @Param("excludeId") Integer excludeId);
    
    /**
     * 检查部门名称是否唯一
     */
    boolean isDepartmentNameUnique(@Param("name") String name, @Param("excludeId") Integer excludeId);
}